package io.renren.modules.cgs.controller;

import java.util.List;
import java.util.Map;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import io.renren.modules.cgs.entity.TCgsBusinessBookInfoEntity;
import io.renren.modules.cgs.service.TCgsBusinessBookInfoService;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.Query;
import io.renren.common.utils.R;


/**
 * 
 * 
 * @author zhubsh
 * @email sd_zhusbh@163.com
 * @date 2018-11-22 16:15:58
 */
@RestController
@RequestMapping("cgs/tcgsbusinessbookinfo")
public class TCgsBusinessBookInfoController {
	@Autowired
	private TCgsBusinessBookInfoService tCgsBusinessBookInfoService;
	
	/**
	 * 列表
	 */
	@RequestMapping("/list")
	@RequiresPermissions("cgs:tcgsbusinessbookinfo:list")
	public R list(@RequestParam Map<String, Object> params){
		//查询列表数据
        Query query = new Query(params);

		List<TCgsBusinessBookInfoEntity> tCgsBusinessBookInfoList = tCgsBusinessBookInfoService.queryList(query);
		int total = tCgsBusinessBookInfoService.queryTotal(query);
		
		PageUtils pageUtil = new PageUtils(tCgsBusinessBookInfoList, total, query.getLimit(), query.getCurrPage());
		
		return R.ok().put("page", pageUtil);
	}
	
	
	/**
	 * 信息
	 */
	@RequestMapping("/info/{id}")
	@RequiresPermissions("cgs:tcgsbusinessbookinfo:info")
	public R info(@PathVariable("id") String id){
		TCgsBusinessBookInfoEntity tCgsBusinessBookInfo = tCgsBusinessBookInfoService.queryObject(id);
		
		return R.ok().put("tCgsBusinessBookInfo", tCgsBusinessBookInfo);
	}
	
	/**
	 * 保存
	 */
	@RequestMapping("/save")
	@RequiresPermissions("cgs:tcgsbusinessbookinfo:save")
	public R save(@RequestBody TCgsBusinessBookInfoEntity tCgsBusinessBookInfo){
		tCgsBusinessBookInfoService.save(tCgsBusinessBookInfo);
		
		return R.ok();
	}
	
	/**
	 * 修改
	 */
	@RequestMapping("/update")
	@RequiresPermissions("cgs:tcgsbusinessbookinfo:update")
	public R update(@RequestBody TCgsBusinessBookInfoEntity tCgsBusinessBookInfo){
		tCgsBusinessBookInfoService.update(tCgsBusinessBookInfo);
		
		return R.ok();
	}
	
	/**
	 * 删除
	 */
	@RequestMapping("/delete")
	@RequiresPermissions("cgs:tcgsbusinessbookinfo:delete")
	public R delete(@RequestBody String[] ids){
		tCgsBusinessBookInfoService.deleteBatch(ids);
		
		return R.ok();
	}

    @PostMapping("/queryCgsForList")
	public R queryCgsForList(){
        List<Map<String, Object>> maps = tCgsBusinessBookInfoService.queryCgsForList();
        R r = new R();
        r.put("list", maps);
        return r;
    }
	
}
